home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pinstaller / tests / install.py < prev    next >
Text File  |  2005-08-22  |  4KB  |  95 lines

  1. #!/usr/bin/python
  2. # Copyright 1999-2005 Gentoo Foundation
  3. # This source code is distributed under the terms of version 2 of the GNU
  4. # General Public License as published by the Free Software Foundation, a copy
  5. # of which can be found in the main directory of this project.
  6. import sys
  7. import GLIUtility
  8. import GLIArchitectureTemplate
  9. import GLIInstallProfile
  10. import GLIClientConfiguration
  11.  
  12. def usage():
  13.     print "Usage: " + sys.argv[0] + " <installprofile.xml> [command [command ...]]\n"
  14.     print "command is one of:\n"
  15.     print "\tpartition              add, remove, and resize partitions"
  16.     print "\tmount                  mount all partitions"
  17.     print "\tmount_net              mount network shares"
  18.     print "\tunpack                 unpack stage tarball"
  19.     print "\tprep_make_conf         prepare the make.conf"
  20.     print "\tportage_tree           portage tree magic"
  21.     print "\tprep_chroot            prepare the chroot"
  22.     print "\tbootstrap              duh :P"
  23.     print "\temerge_system          duh :P"
  24.     print "\ttimezone               set timezone"
  25.     print "\temerge_kernel          install the kernel sources"
  26.     print "\tbuild_kernel           build the kernel"
  27.     print "\tlogger                 install logger"
  28.     print "\tcrond                  install cron daemon"
  29.     print "\tfstools                install filesystem tools"
  30.     print "\tnetwork                configure network"
  31.     print "\tbootloader             install and configure bootloader"
  32.     print "\tconfig_files           update config files"
  33.     print "\tupdate_rc_conf         update rc.conf"
  34.     print "\tset_users              set up the users"
  35.     print "\tetc_portage            set up the files in /etc/portage"
  36.     print "\tinstall_packages       install required packages"
  37.     print "\tunmount                unmount all filesystems"
  38.  
  39. def not_working():
  40.     print "This is a placeholder. This function does nothing right now."
  41.  
  42. if len(sys.argv) < 3:
  43.     usage()
  44.     sys.exit(1)
  45.  
  46. progname = sys.argv.pop(0)
  47. xmlfile = sys.argv.pop(0)
  48.  
  49. if not GLIUtility.is_file(xmlfile):
  50.     print "The XML file '" + xmlfile + "' cannot be accessed.\n"
  51.     usage()
  52.     sys.exit(1)
  53.  
  54. client_profile = GLIClientConfiguration.ClientConfiguration()
  55. client_profile.set_root_mount_point(None, "/mnt/gentoo", None)
  56. install_profile = GLIInstallProfile.InstallProfile()
  57. install_profile.parse(xmlfile)
  58.  
  59. template =  __import__('templates' + '/' + 'x86ArchitectureTemplate')
  60. archtemplate = getattr(template, 'x86ArchitectureTemplate')(client_profile, install_profile, False)
  61.  
  62. #archtemplate = GLIArchitectureTemplate.ArchitectureTemplate(install_profile=install_profile)
  63.  
  64. operations = {
  65.               'partition': archtemplate.partition,
  66.               'mount': archtemplate.mount_local_partitions,
  67.               'mount_net': archtemplate.mount_network_shares,
  68.               'unpack': archtemplate.unpack_stage_tarball,
  69.               'prep_make_conf': archtemplate.configure_make_conf,
  70.               'portage_tree': archtemplate.install_portage_tree,
  71.               'prep_chroot': archtemplate.prepare_chroot,
  72.               'bootstrap': archtemplate.stage1,
  73.               'emerge_system': archtemplate.stage2,
  74.               'timezone': archtemplate.set_timezone,
  75.               'emerge_kernel': archtemplate.emerge_kernel_sources,
  76.               'build_kernel': archtemplate.build_kernel,
  77.               'logger': archtemplate.install_logging_daemon,
  78.               'crond': archtemplate.install_cron_daemon,
  79.               'fstools': archtemplate.install_filesystem_tools,
  80.               'network': archtemplate.setup_network_post,
  81.               'bootloader': archtemplate.install_bootloader,
  82.               'config_files': archtemplate.update_config_files,
  83.               'update_rc_conf': archtemplate.configure_rc_conf,
  84.               'set_users': archtemplate.set_users,
  85.               'etc_portage': archtemplate.set_etc_portage,
  86.               'install_packages': archtemplate.install_packages,
  87.               'unmount': not_working
  88.             }
  89.  
  90. for action in sys.argv:
  91.     if operations.has_key(action):
  92.         operations[action]()
  93.     else:
  94.         print "Operation '" + action + "' is not valid"
  95.